import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/assets/iconfont/iconfont.css'
import '@/assets/styles/base.css'
import 'amfe-flexible'
import axios from 'axios'

import { Popup, Swipe, SwipeItem, NoticeBar, Toast, Picker, Dialog, Cascader, Field } from 'vant'
import component from './tool/component'
import 'vant/lib/index.css'

import ECharts from 'vue-echarts/components/ECharts.vue'
import 'echarts/lib/chart/bar' /* 柱状图 */
import 'echarts/lib/chart/pie' /* 饼图 */
import 'echarts/lib/chart/scatter' /* 散点图 */
import 'echarts/lib/chart/effectScatter' /* 散点图 */

import 'echarts/lib/component/tooltip'
import 'echarts/lib/component/title'
import 'echarts/lib/component/legend'
import echarts from 'echarts'
Vue.prototype.$echarts = echarts

Vue.use(Popup).use(Swipe).use(SwipeItem).use(NoticeBar).use(Toast).use(Picker).use(Dialog).use(Cascader).use(Field)
component(Vue)
Vue.prototype.$axios = axios
axios.defaults.baseURL = '/api'
Vue.component('echarts', ECharts)

Vue.config.productionTip = false
router.beforeEach((to, from, next) => {
  console.log(window.localStorage.getItem('dateInfo'))
  var num = (+new Date() - window.localStorage.getItem('dateInfo')) / 60 / 60 / 60
  if (window.localStorage.getItem('userInfo') && num < 30) {
    next()
  } else if (to.name === 'logins') {
    next()
  } else {
    next({ path: '/login' })
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
